package tests;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

public class TestSpring {
	@Test
	public void testBeanCreation() {
		String repositoryFile="classpath:bankapp-test-spring-beans.xml";
		ClassPathResource cpres = new ClassPathResource(repositoryFile);
		
		Assert.assertNotNull(cpres);
		Assert.assertTrue(cpres.isReadable());
		
		ClassPathXmlApplicationContext repositoryContext = new ClassPathXmlApplicationContext(repositoryFile);
		
		
		IUser user = repositoryContext.getBean("user", IUser.class);
		
		Assert.assertNotNull(user);
		
		Assert.assertNotNull(user.getName());
		
		IEnviroment enviroment = repositoryContext.getBean("enviroment", Enviroment.class);
		System.out.println(enviroment.getEnviromentLogicalName());
	}
}
